package cn.wsalix.biz.entity;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import lombok.Data;
import lombok.EqualsAndHashCode;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import cn.anlaser.entity.SimpleEntity;
import cn.wsalix.admin.entity.SysUser;

/**
 * @author jskyme
 * 赞助
 */
@Entity
@DynamicInsert
@DynamicUpdate
@Table(name = "SPONSOR")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@EntityListeners({ AuditingEntityListener.class })
@Data
@EqualsAndHashCode(callSuper = false)
public class Sponsor extends SimpleEntity{
	@ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch = FetchType.LAZY)
	@JoinColumn(foreignKey = @ForeignKey(name = "FK_SPONSOR_ACTIVITY"), name = "ACTIVITY_ID")
	private Activity activity;//捐助跟着活动走
	
	@ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch = FetchType.LAZY)
	@JoinColumn(foreignKey = @ForeignKey(name = "FK_SPONSOR_RECEIVER"), name = "RECEIVER_ID")
	private SysUser receiver;//捐助接待人，由活动负责人中选择
	
	private String title;//赞助标题
	private String content;
	private String contact;//联系人

	@ManyToOne(cascade = CascadeType.MERGE, optional = true, fetch = FetchType.LAZY)
	@JoinColumn(foreignKey = @ForeignKey(name = "FK_SPONSOR_USER"), name = "MASTER_ID")
	private SysUser master;//负责人
}
